var express = require('express'),
    router = express.Router(),
    productModel = require('../models/product');
router.get('/product/getproducts', function (req, res) {
    var currentPage = req.query.currentPage;
    productModel.getProducts(currentPage, function (products, msg) {
        if (products.length > 0) {
            res.status(200).json({status: true, msg: '产品数据获取成功', data: products, totalpage: msg});
        } else {
            res.status(200).json({status: false, msg: msg});
        }
    })
});
router.get('/product/getproductsbystyle', function (req, res) {
    var currentPage = req.query.currentPage,
        style = req.query.productStyle;
    productModel.getProductsByStyle(currentPage, style, function (products, msg) {
        if (products.length > 0) {
            res.status(200).json({status: true, msg: '产品数据获取成功', data: products, totalpage: msg})
        } else {
            res.status(200).json({status: false, msg: msg});
        }
    })

});
router.get('/product/getproductsbynum', function (req, res) {
        var num=req.query;
        productModel.getProductsByNum(num,function (product,msg) {
            if (product.length>0){
                res.status(200).json({status:true,msg:'详情数据获取成功',data:product});
            }else {
                res.status(200).json({status:false,msg:msg});
            }
        })
});
module.exports = router;